package com.example.module_marketers

import android.util.Log
import androidx.activity.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.lib_base.path.RouterPath
import com.bw.lib_common.view.BaseMvvmActivity
import com.example.module_marketers.adapter.BusinessDetailPhotoAdapter
import com.example.module_marketers.databinding.ActivityMarketersDetailBinding
import com.example.module_marketers.viewmodel.MarketersViewModel
/**
 * 智慧园区-04-商家推荐V1.1-张亦婷-20250511
 */
@Route(path = RouterPath.MODULE_BUSINESS_PROFILE_DETAIL_ACTIVITY)
class MarketersDetailActivity : BaseMvvmActivity<ActivityMarketersDetailBinding>() {
    private val viewModel: MarketersViewModel by viewModels()
    lateinit var businessDetailPhotoAdapter: BusinessDetailPhotoAdapter
    @Autowired
    @JvmField
    var id:Int =0
    override fun initViews() {
        super.initViews()
        ARouter.getInstance().inject(this)
        Log.d("detail_id","${id}")
        binding.back.setOnClickListener {
            finish()
        }
        businessDetailPhotoAdapter=BusinessDetailPhotoAdapter()
        binding.businessRv.adapter=businessDetailPhotoAdapter
        binding.businessRv.layoutManager= LinearLayoutManager(this)
        viewModel.getBusinessProfileDetail(id)
    }

    override fun observeDataChange() {
        viewModel.getBusinessProfileDetailSuccess.observe(this){
            binding.entity=it
            businessDetailPhotoAdapter.data.clear()
            businessDetailPhotoAdapter.data.addAll(it.photos)
            businessDetailPhotoAdapter.notifyDataSetChanged()
        }
    }

    override fun getLayoutId(): Int =R.layout.activity_marketers_detail
}